<?php

class AdminController extends Controller
{    
    public static function pre()
    {
        parent::pre();        
        
        if(!UserModel::isLoggedIn()||!UserModel::checkPrivileges(Privileges::ADMIN)) 
        { 
            flash_message::setMessage("Dostęp wymaga uprawnień administratora!!!");
            System::redirect('index.php?controller=index'); 
            die('error');
        }
        self::setTemplate('admin');    
        
    }
    
    public static function index() 
    {
        self::setLayout('index');
        View::assign('zmienna', 'test');
    }
    
    public static function users()
    {
        require_once "model/UserModel.php";
        
        View::assign('users', UserModel::fetchAll());      
        
        self::setTemplate('admin');  
        self::setLayout('page');
        self::setContentFile('parts/user/list');
    }
    
    public static function users_history()
    {
        
        require_once "model/UserHistoryModel.php";
        
        View::assign('users_history', UserHistoryModel::fetchAll());      
        
        self::setTemplate('admin');  
        self::setLayout('page');
        self::setContentFile('parts/user/history');
    }
}




?>
